<script setup lang="ts">

import mockApi from "@/api/mockApi.js";

import {ref} from 'vue'
//页面数据请求
let tableData = ref([]);
const getList = () => {
 mockApi
   .findAll()
   .then((res) => {
        console.log(res)
     if (res.code === 200){ 
      
        // tableData.push.apply(tableData, res.data);
        tableData.value = res.dataList
      }
    })
    .catch(function (error) {
      console.log(error);
    });
};

const columns=[
          {
            title: '姓名',
            dataIndex: 'name',
            key: 'name',
          },
          {
            title: '年龄',
            dataIndex: 'age',
            key: 'age',
          },
          {
            title: '住址',
            dataIndex: 'city',
            key: 'city',
          },
]
//直接调用请求方法
//getList(); 

</script>

<template>
  <div>
    <h1>Mockjs</h1>
    <a-button @click="getList"> test mock </a-button>


    <a-table :dataSource="tableData" :columns="columns" />
  </div>
</template>

<style scoped>

</style>